class Configindex < ActiveRecord::Migration
  def self.up
    
    remove_index :asin_infos, :name => "index_tr"
    remove_index :asin_infos, :name => "index_sr"
    remove_index :asin_infos, :name => "index_trr"
    remove_index :asin_infos, :name => "index_arr"
    remove_index :asin_infos, :name => "index_pr"
    remove_index :asin_infos, :name => "index_npr"
    remove_index :asin_infos, :name => "index_pdr"
    remove_index :asin_infos, :name => "index_ncr"

    remove_index :asin_infos, :name => "index_aid_tr"
    remove_index :asin_infos, :name => "index_aid_sr"
    remove_index :asin_infos, :name => "index_aid_trr"
    remove_index :asin_infos, :name => "index_aid_arr"
    remove_index :asin_infos, :name => "index_aid_pr"
    remove_index :asin_infos, :name => "index_aid_npr"
    remove_index :asin_infos, :name => "index_aid_pdr"
    remove_index :asin_infos, :name => "index_aid_ncr"

    remove_index :asin_infos, :name => "index_aid_pid_tr"
    remove_index :asin_infos, :name => "index_aid_pid_sr"
    remove_index :asin_infos, :name => "index_aid_pid_trr"
    remove_index :asin_infos, :name => "index_aid_pid_arr"
    remove_index :asin_infos, :name => "index_aid_pid_pr"
    remove_index :asin_infos, :name => "index_aid_pid_npr"
    remove_index :asin_infos, :name => "index_aid_pid_pdr"
    remove_index :asin_infos, :name => "index_aid_pid_ncr"


    remove_index :asin_infos, :name => "index_aid_g_tr"
    remove_index :asin_infos, :name => "index_aid_g_sr"
    remove_index :asin_infos, :name => "index_aid_g_trr"
    remove_index :asin_infos, :name => "index_aid_g_arr"
    remove_index :asin_infos, :name => "index_aid_g_pr"
    remove_index :asin_infos, :name => "index_aid_g_npr"
    remove_index :asin_infos, :name => "index_aid_g_pdr"
    remove_index :asin_infos, :name => "index_aid_g_ncr"

    remove_index :asin_infos, :name => "index_aid_pid_g_tr"
    remove_index :asin_infos, :name => "index_aid_pid_g_sr"
    remove_index :asin_infos, :name => "index_aid_pid_g_trr"
    remove_index :asin_infos, :name => "index_aid_pid_g_arr"
    remove_index :asin_infos, :name => "index_aid_pid_g_pr"
    remove_index :asin_infos, :name => "index_aid_pid_g_npr"
    remove_index :asin_infos, :name => "index_aid_pid_g_pdr"
    remove_index :asin_infos, :name => "index_aid_pid_g_ncr"

    remove_index :asin_infos, :name => "index_pid_g_tr"
    remove_index :asin_infos, :name => "index_pid_g_sr"
    remove_index :asin_infos, :name => "index_pid_g_trr"
    remove_index :asin_infos, :name => "index_pid_g_arr"
    remove_index :asin_infos, :name => "index_pid_g_pr"
    remove_index :asin_infos, :name => "index_pid_g_npr"
    remove_index :asin_infos, :name => "index_pid_g_pdr"
    remove_index :asin_infos, :name => "index_pid_g_ncr"

    remove_index :asin_infos, :name => "index_pid_tr"
    remove_index :asin_infos, :name => "index_pid_sr"
    remove_index :asin_infos, :name => "index_pid_trr"
    remove_index :asin_infos, :name => "index_pid_arr"
    remove_index :asin_infos, :name => "index_pid_pr"
    remove_index :asin_infos, :name => "index_pid_npr"
    remove_index :asin_infos, :name => "index_pid_pdr"
    remove_index :asin_infos, :name => "index_pid_ncr"

    remove_index :asin_infos, :name => "index_g_tr"
    remove_index :asin_infos, :name => "index_g_sr"
    remove_index :asin_infos, :name => "index_g_trr"
    remove_index :asin_infos, :name => "index_g_arr"
    remove_index :asin_infos, :name => "index_g_pr"
    remove_index :asin_infos, :name => "index_g_npr"
    remove_index :asin_infos, :name => "index_g_pdr"
    remove_index :asin_infos, :name => "index_g_ncr"

        # N N N パターン
    add_index :asin_infos, [:title_rank], :name => "index_tr"
    add_index :asin_infos, [:sales_rank], :name => "index_sr"
    add_index :asin_infos, [:total_reviews_rank], :name => "index_trr"
    add_index :asin_infos, [:average_rating_rank], :name => "index_arr"
    add_index :asin_infos, [:price_rank], :name => "index_pr"
    add_index :asin_infos, [:number_ofpages_rank], :name => "index_npr"
    add_index :asin_infos, [:publication_date_rank], :name => "index_pdr"


    # A N N パターン
    add_index :asin_infos, [:author_id, :title_rank], :name => "index_aid_tr"
    add_index :asin_infos, [:author_id, :sales_rank], :name => "index_aid_sr"
    add_index :asin_infos, [:author_id, :total_reviews_rank], :name => "index_aid_trr"
    add_index :asin_infos, [:author_id, :average_rating_rank], :name => "index_aid_arr"
    add_index :asin_infos, [:author_id, :price_rank], :name => "index_aid_pr"
    add_index :asin_infos, [:author_id, :number_ofpages_rank], :name => "index_aid_npr"
    add_index :asin_infos, [:author_id, :publication_date_rank], :name => "index_aid_pdr"


    # A P N パターン
    add_index :asin_infos, [:author_id, :publisher_id, :title_rank], :name => "index_aid_pid_tr"
    add_index :asin_infos, [:author_id, :publisher_id, :sales_rank], :name => "index_aid_pid_sr"
    add_index :asin_infos, [:author_id, :publisher_id, :total_reviews_rank], :name => "index_aid_pid_trr"
    add_index :asin_infos, [:author_id, :publisher_id, :average_rating_rank], :name => "index_aid_pid_arr"
    add_index :asin_infos, [:author_id, :publisher_id, :price_rank], :name => "index_aid_pid_pr"
    add_index :asin_infos, [:author_id, :publisher_id, :number_ofpages_rank], :name => "index_aid_pid_npr"
    add_index :asin_infos, [:author_id, :publisher_id, :publication_date_rank], :name => "index_aid_pid_pdr"


    # A N G パターン
    add_index :asin_infos, [:author_id, :genre, :title_rank], :name => "index_aid_g_tr"
    add_index :asin_infos, [:author_id, :genre, :sales_rank], :name => "index_aid_g_sr"
    add_index :asin_infos, [:author_id, :genre, :total_reviews_rank], :name => "index_aid_g_trr"
    add_index :asin_infos, [:author_id, :genre, :average_rating_rank], :name => "index_aid_g_arr"
    add_index :asin_infos, [:author_id, :genre, :price_rank], :name => "index_aid_g_pr"
    add_index :asin_infos, [:author_id, :genre, :number_ofpages_rank], :name => "index_aid_g_npr"
    add_index :asin_infos, [:author_id, :genre, :publication_date_rank], :name => "index_aid_g_pdr"



    # A P G パターン
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :title_rank], :name => "index_aid_pid_g_tr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :sales_rank], :name => "index_aid_pid_g_sr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :total_reviews_rank], :name => "index_aid_pid_g_trr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :average_rating_rank], :name => "index_aid_pid_g_arr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :price_rank], :name => "index_aid_pid_g_pr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :number_ofpages_rank], :name => "index_aid_pid_g_npr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :publication_date_rank], :name => "index_aid_pid_g_pdr"

    # N P G パターン
    add_index :asin_infos, [:publisher_id, :genre, :title_rank], :name => "index_pid_g_tr"
    add_index :asin_infos, [:publisher_id, :genre, :sales_rank], :name => "index_pid_g_sr"
    add_index :asin_infos, [:publisher_id, :genre, :total_reviews_rank], :name => "index_pid_g_trr"
    add_index :asin_infos, [:publisher_id, :genre, :average_rating_rank], :name => "index_pid_g_arr"
    add_index :asin_infos, [:publisher_id, :genre, :price_rank], :name => "index_pid_g_pr"
    add_index :asin_infos, [:publisher_id, :genre, :number_ofpages_rank], :name => "index_pid_g_npr"
    add_index :asin_infos, [:publisher_id, :genre, :publication_date_rank], :name => "index_pid_g_pdr"


    # N P N パターン
    add_index :asin_infos, [:publisher_id, :title_rank], :name => "index_pid_tr"
    add_index :asin_infos, [:publisher_id, :sales_rank], :name => "index_pid_sr"
    add_index :asin_infos, [:publisher_id, :total_reviews_rank], :name => "index_pid_trr"
    add_index :asin_infos, [:publisher_id, :average_rating_rank], :name => "index_pid_arr"
    add_index :asin_infos, [:publisher_id, :price_rank], :name => "index_pid_pr"
    add_index :asin_infos, [:publisher_id, :number_ofpages_rank], :name => "index_pid_npr"
    add_index :asin_infos, [:publisher_id, :publication_date_rank], :name => "index_pid_pdr"


    # N N G パターン
    add_index :asin_infos, [:genre, :title_rank], :name => "index_g_tr"
    add_index :asin_infos, [:genre, :sales_rank], :name => "index_g_sr"
    add_index :asin_infos, [:genre, :total_reviews_rank], :name => "index_g_trr"
    add_index :asin_infos, [:genre, :average_rating_rank], :name => "index_g_arr"
    add_index :asin_infos, [:genre, :price_rank], :name => "index_g_pr"
    add_index :asin_infos, [:genre, :number_ofpages_rank], :name => "index_g_npr"
    add_index :asin_infos, [:genre, :publication_date_rank], :name => "index_g_pdr"


    
  end

  def self.down
    add_index :asin_infos, [:number_ofclicks_rank], :name => "index_ncr"
    add_index :asin_infos, [:author_id, :number_ofclicks_rank], :name => "index_aid_ncr"
    add_index :asin_infos, [:author_id, :publisher_id, :number_ofclicks_rank], :name => "index_aid_pid_ncr"
    add_index :asin_infos, [:author_id, :genre, :number_ofclicks_rank], :name => "index_aid_g_ncr"
    add_index :asin_infos, [:author_id, :publisher_id, :genre, :number_ofclicks_rank], :name => "index_aid_pid_g_ncr"
    add_index :asin_infos, [:publisher_id, :genre, :number_ofclicks_rank], :name => "index_pid_g_ncr"
    add_index :asin_infos, [:publisher_id, :number_ofclicks_rank], :name => "index_pid_ncr"
    add_index :asin_infos, [:genre, :number_ofclicks_rank], :name => "index_g_ncr"
  end
end
